package org.jetnuke.modules.admin.picture;

import java.util.Random;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.velocity.VelocityContext;
import org.jetnuke.common.ActionForward;
import org.jetnuke.common.IAction;
import org.jetnuke.common.IAdminInfo;
import org.jetnuke.common.IModuleInfo;
import org.jetnuke.common.IUserInfo;
import org.jetnuke.dao.DataAccessDriver;
import org.jetnuke.dao.PictureSettingsDAO;
import org.jetnuke.entities.PictureSettings;
import org.jetnuke.util.JetUtil;

public class UpdatePictureSettings implements IAction {
	String license;
	int limit;
	public ActionForward exec(HttpServletRequest request,
			HttpServletResponse response, VelocityContext vc, IModuleInfo info,
			String op, IUserInfo ui, IAdminInfo ai) throws Exception {
		if(ai==null || !ai.IsSuperUser())
			return null;
		PictureSettingsDAO psm=DataAccessDriver.getInst().newPictureSettingsDAO();
		PictureSettings bs=psm.get();
		bs.setLICENSE(license);
		bs.setLIMIT(limit);
		psm.update(bs);
		JetUtil.redirect(vc,response,request.getContextPath()+"/do/admin/picture_settings?rand="+new Random().nextInt());
		return null;
	}
	public void setLicense(String license) {
		this.license = license;
	}
	public void setLimit(int limit) {
		this.limit = limit;
	}

}
